package com.zp95sky.cloud.examples.mybatis.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zp95sky.cloud.examples.mybatis.entity.T1;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface T1Mapper extends BaseMapper<T1> {

    @Insert("insert into t1(id, col1, col2, col3) values (#{id}, #{col1}, #{col2}, #{col3})")
    int customInsert(T1 t1);

    @Select("select id, col1, col2, col3 from t1")
    List<T1> customSelectList();

    int customInsert2(T1 t1);

    List<T1> customSelectList2();

    @DS("master")
    int customInsert3(T1 t1);

    @DS("slave")
    List<T1> customSelectList3();

    @DS("master")
    @Insert("insert into t1(id, col1, col2, col3) values (#{id}, #{col1}, #{col2}, #{col3})")
    int customInsert4(T1 t1);

    @DS("slave")
    @Select("select id, col1, col2, col3 from t1")
    List<T1> customSelectList4();

}
